The Building Blocks of a Central Application
Table of Contents
Receiving a Blast
To receive the Blast sent from the sample application, I made another Central application that I set up to receive address blasts. I've included source files for this in the sample files download as well. Again, it's very simple and certainly no killer application; I'm just trying to show how to use a blast sent from another application. As you can probably guess, I've set this application up to receive a zip code from the sample application and then do something with it. The blast receiver application connects to a web service to look up information about any U.S. zip code. It could also look up information about area codes, but I didn't set up a blast for that.
To receive the zip code blast from the sample application, I put the following code inside the Zip and Area Code Info application:
// function that is called when a Blast is received
onSelectedItem = function (data) {
// loop through the data
for (var i = 0; i<data.length; i++) {
// this app only accepts addresses, so check for that
if (data[i].address != null) {
// display the received zip code in text field
var zip = data[i].address.postalCode;
container.selectedChild.inputText.text = zip;
container.selectedChild.blasted._visible = true;
}
}
}
For a blast to work correctly, the following also necessary in the product.xml file of the application receiving a blast. It is not necessary in the one sending a blast.
<supportedTypes namespace="http://www.w3.org/2001/XMLSchema" schema="http://download.macromedia.com/pub/central/schemas/CentralData.xsd"> <type>any</type> </supportedTypes>
If the "blastable" data originates in the pod, you insert it in the <pod> tags. If it originates in the application itself, you insert it in the <application> tags. For my example, I put it within the <application> tags, and my blast feature was complete. Instead of type any, you can also be more restrictive. The list of available types includes email, im, link, coordinates, phone, contact, publication, business, location, and, of course, address.